home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 11346 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.2 KB  |  56 lines

  1. Path: newsfeed.tip.net!dataphone!newsmaster
  2. From: skorpio@dataphone.se (Jarmo Paavilainen)
  3. Newsgroups: comp.lang.c
  4. Subject: Unable to use 'delete' after 'new'
  5. Date: 23 Mar 1996 09:38:03 GMT
  6. Organization: Dataphone Communication Networks
  7. Message-ID: <4j0gpr$5u6@nic.dataphone.se>
  8. References: <4iudtl$eni@lisa.iosphere.net>
  9. Reply-To: skorpio@dataphone.se
  10. NNTP-Posting-Host: nikson.dataphone.se
  11. X-Newsreader: NeoLogic News for OS/2 [version: 4.5 YO Beta]
  12.  
  13. In message <4iudtl$eni@lisa.iosphere.net> - ianq@sonetis.com (Ian V.
  14. Quickmire) writes:
  15.  
  16. ..
  17. :>The trick here is that I need to return this array to the calling
  18. function,
  19. :>which then processes the data. 
  20. ..
  21.  
  22. In C++ this should work.
  23.  
  24. void MakeArray(int *&array)
  25. {
  26. array = new int[length];
  27. }
  28.  
  29. /*
  30. or should it be 
  31. void MakeArray(int &*array)
  32.  
  33. BUT
  34.  
  35. void MakeArray(int *array)
  36.  
  37. Will not give any compile errors but it will not transfer the pointer.
  38. */
  39.  
  40. main()
  41. {
  42. int *array;
  43.  
  44. MakeArray(array);
  45. delete[] array;
  46.  
  47. return 0;
  48. }
  49.  
  50. Take care,
  51. Skorpio
  52. _________________________________________________________________________
  53.  Jarmo Paavilainen, Skorpio                         skorpio@dataphone.se
  54.  Sweden                                 http://www.dataphone.se/~skorpio
  55.  
  56.